/*
 * @Description: 服务请求配置
 * @Author: zhangweigang
 * @Date: 2021-03-21 19:33:31
 * @LastEditTime: 2021-04-05 18:24:39
 * @LastEditors: zhangweigang
 */
import { request } from './index.js'
import qs from 'qs'
// 代理跟路径
const api = '/api'

const bookShareManagerInfoAipService = {
  // 管理员注册
  adminRegisterInfo(params) {
    return request({
      url: api + '/users',
      method: 'POST',
      data: params
    })
  },
  // 管理员登录
  adminLoginInfo(params) {
    return request({
      url: api + '/sys/login',
      method: 'POST',
      data: qs.stringify(params)
    })
  },
  // 获取用户分页信息
  getUserListInfo(offset, pageSize, pageNum) {
    return request({
      url: api + '/users?limit=10&offset=' + offset + '&pageSize=' + pageSize + '&pageNum=' + pageNum + '&isAsc=asc',
      method: 'GET'
    })
  },
  // 修改用户信息
  editUserInfo(params) {
    return request({
      url: api + '/users',
      method: 'PUT',
      data: params
    })
  },
  // 获取用户所有信息
  getUserAllInfo() {
    return request({
      url: api + '/users',
      method: 'GET'
    })
  },
  // 获取公告列表数据
  getNoticeListDataInfo() {
    return request({
      url: api + '/bsNotice/selectPageByParam',
      method: 'POST',
      data: {}
    })
  },
  // 根据ID获取公告内容
  getNoticeByIdContent(id) {
    return request({
      url: api + '/bsNotice/selectOne?id=' + id,
      method: 'GET',
      params: qs.stringify(id)
    })
  },
  // 发布公告
  declareNewNotice(params) {
    return request({
      url: api + '/bsNotice',
      method: 'POST',
      data: params
    })
  },
  // 获取公告分页数据
  getAnnouncePagination(pageNum, pageSize) {
    return request({
      headers: {
        'Content-Type': 'application/json;charset=UTF-8'
      },
      url: api + '/bsNotice/selectPageByParam?pageNum=' + pageNum + '&' + 'pageSize=' + pageSize,
      method: 'POST',
      data: {}
    })
  },
  // 根据标题查询公告
  accordToTitleQuery(keys) {
    return request({
      url: api + '/bsNotice/selectPageByParam',
      method: 'POST',
      data: { noticeTitle: keys }
    })
  },
  // 更新公告数据
  updataNoticeByID(params) {
    return request({
      url: api + '/bsNotice',
      method: 'PUT',
      data: params
    })
  },
  // 删除公告
  deleteNoticeById(id) {
    return request({
      url: api + '/bsNotice?id=' + id,
      method: 'DELETE',
      data: qs.stringify(id)
    })
  },
  // 获取所有分类
  getBookCateInfo() {
    return request({
      url: api + '/bsBookCategory/selectAll',
      method: 'GET'
    })
  },

  // 添加分类
  addCateData(params) {
    return request({
      url: api + '/bsBookCategory',
      method: 'POST',
      data: params
    })
  },
  // 删除分类
  deleteByIdCate(id) {
    return request({
      url: api + '/bsBookCategory?id=' + id,
      method: 'DELETE',
      data: qs.stringify(id)
    })
  },
  // 修改分类
  modifyCateInfo(params) {
    return request({
      url: api + '/bsBookCategory',
      method: 'PUT',
      data: params
    })
  },
  // 根据Id获取分类名称
  getCateNameById(id) {
    return request({
      url: api + '/bsBookCategory/selectOne?id=' + id,
      method: 'GET',
      params: qs.stringify(id)
    })
  },
  // 获取所有留言信息
  getLeaveInfoData() {
    return request({
      url: api + '/bsComment/selectPageByParam',
      method: 'POST',
      data: {}
    })
  },
  // 留言分页查询
  getLeavePagination(pageNum, pageSize) {
    return request({
      headers: {
        'Content-Type': 'application/json;charset=UTF-8'
      },
      url: api + '/bsComment/selectPageByParam?pageNum=' + pageNum + '&' + 'pageSize=' + pageSize,
      method: 'POST',
      data: {}
    })
  },
  // 根据留言主体查询
  accordToSubjectQuery(keys) {
    return request({
      url: api + '/bsComment/selectPageByParam',
      method: 'POST',
      data: { subject: keys }
    })
  },
  // 评论回复
  replyLeaveInfo(params) {
    return request({
      url: api + '/bsReply',
      method: 'POST',
      data: params
    })
  },
  // 删除留言
  removeByIDLeave(id) {
    return request({
      url: api + '/bsComment?id=' + id,
      method: 'DELETE',
      data: qs.stringify(id)
    })
  },
  // 单个帖子回复查询
  getSoleReplayInfo(id) {
    return request({
      url: api + '/bsReply/selectTreeData',
      method: 'GET',
      params: { commentId: id }
    })
  },
  // 书籍分页数据
  getBookPagination(pageNum, pageSize) {
    return request({
      url: api + '/bsBook/selectPageByParam?pageNum=' + pageNum + '&' + 'pageSize=' + pageSize,
      method: 'POST',
      data: {}
    })
  },
  // 非共享书籍分页数据
  getNoBookPagination(pageNum, pageSize, params) {
    return request({
      url: api + '/bsBook/selectPageByParam?pageNum=' + pageNum + '&' + 'pageSize=' + pageSize,
      method: 'POST',
      data: params
    })
  },
  // 根据书籍名称查询书籍信息
  getBookByName(name) {
    return request({
      url: api + '/bsBook/selectPageByParam',
      method: 'POST',
      data: name
    })
  },
  // 书籍审核
  bookCopyRightReview(params) {
    return request({
      url: api + '/bsBook/audit',
      method: 'POST',
      data: params
    })
  },
  // 删除书籍
  removeBookById(id) {
    return request({
      url: api + '/bsBook?id=' + id,
      method: 'DELETE',
      data: qs.stringify(id)
    })
  },
  // 修改书籍
  modifyBookInfo(params) {
    return request({
      url: api + '/bsBook',
      method: 'PUT',
      data: params
    })
  }
}

export default bookShareManagerInfoAipService
